home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Gold Collection / Software Vault - The Gold Collection (American Databankers) (1993).ISO / cdr49 / 347_01.zip / TAVL_SDT.C < prev    next >
C/C++ Source or Header  |  1993-04-13  |  798b  |  29 lines

  1. /*:file:version:date: "%n    V.%v;  %f"
  2.  * "TAVL_SDT.C    V.10;  27-Apr-91,12:16:20"
  3.  *
  4.  *  Purpose: Change data in existing node.
  5.  *
  6.  *  Released to the PUBLIC DOMAIN
  7.  *
  8.  *  Author:                 Bert C. Hughes
  9.  *                          200 N.Saratoga
  10.  *                          St.Paul, MN 55104
  11.  *                          Compuserve 71211,577
  12.  */
  13.  
  14. #include "tavltree.h"
  15.  
  16. int tavl_setdata(TAVL_treeptr tree, TAVL_nodeptr p, void *item)
  17. {
  18.     if (Is_Head(p)) return(TAVL_ILLEGAL_OP);
  19.  
  20.     if ((*tree->cmp)((*tree->key_of)(p->dataptr),(*tree->key_of)(item)))
  21.         return(TAVL_ILLEGAL_OP);  /* Don't allow identifier to change! */
  22.  
  23.     (*tree->free_item)(p->dataptr);
  24.  
  25.     p->dataptr = (*tree->make_item)(item);
  26.  
  27.     return(p->dataptr ? TAVL_OK : TAVL_NOMEM);
  28. }
  29.